﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook {
    import flash.events.*;
    import com.facebook.events.*;
    import com.facebook.delegates.*;
    import com.facebook.net.*;
    import flash.net.*;
    import com.facebook.session.*;
    import com.facebook.commands.auth.*;

    public class Facebook extends EventDispatcher {

        public var waiting_for_login:Boolean;
        protected var _currentSession:IFacebookSession;
        public var connectionErrorMessage:String;

        public function Facebook():void{
        }
        public function post(_arg1:FacebookCall):FacebookCall{
            var _local2:IFacebookCallDelegate;
            if (this._currentSession){
                _arg1.session = this._currentSession;
                _arg1.initialize();
                _local2 = this._currentSession.post(_arg1);
                _arg1.delegate = _local2;
            } else {
                throw (new Error("Cannot post a call; no session has been set."));
            };
            return (_arg1);
        }
        public function startSession(_arg1:IFacebookSession):void{
            this._currentSession = _arg1;
            if (this._currentSession.is_connected){
                dispatchEvent(new FacebookEvent(FacebookEvent.CONNECT, false, false, true));
            } else {
                this._currentSession.addEventListener(FacebookEvent.CONNECT, this.onSessionConnected);
                this._currentSession.addEventListener(FacebookEvent.WAITING_FOR_LOGIN, this.onWaitingForLogin);
            };
        }
        public function grantExtendedPermission(_arg1:String):void{
            navigateToURL(new URLRequest(((((("http://www.facebook.com/authorize.php?api_key=" + this.api_key) + "&v=") + this.api_version) + "&ext_perm=") + _arg1)), "_blank");
        }
        public function refreshSession():void{
            this._currentSession.refreshSession();
        }
        public function logout():void{
            var _local1:ExpireSession = new ExpireSession();
            _local1.addEventListener(FacebookEvent.COMPLETE, this.onLoggedOut, false, 0, true);
            this.post(_local1);
        }
        public function get api_version():String{
            return ((this._currentSession) ? this._currentSession.api_version : null);
        }
        protected function onLoggedOut(_arg1:FacebookEvent):void{
            if (_arg1.success == true){
                this._currentSession.session_key = null;
            };
            dispatchEvent(new FacebookEvent(FacebookEvent.LOGOUT, false, false, _arg1.success, _arg1.data, _arg1.error));
        }
        protected function onWaitingForLogin(_arg1:FacebookEvent):void{
            this.waiting_for_login = true;
            dispatchEvent(new FacebookEvent(FacebookEvent.WAITING_FOR_LOGIN));
        }
        public function login(_arg1:Boolean):void{
            this._currentSession.login(_arg1);
        }
        public function get secret():String{
            return ((this._currentSession) ? this._currentSession.secret : null);
        }
        public function grantPermission(_arg1:Boolean):void{
            var _local2:String = ((("http://www.facebook.com/login.php?return_session=" + (_arg1) ? 1 : 0) + "&api_key=") + this.api_key);
            navigateToURL(new URLRequest(_local2), "_blank");
        }
        public function get is_connected():Boolean{
            return ((this._currentSession) ? this._currentSession.is_connected : false);
        }
        public function get session_key():String{
            return ((this._currentSession) ? this._currentSession.session_key : null);
        }
        public function get uid():String{
            return ((this._currentSession) ? this._currentSession.uid : null);
        }
        protected function onSessionConnected(_arg1:FacebookEvent):void{
            var _local2:IFacebookSession = (_arg1.target as IFacebookSession);
            dispatchEvent(_arg1);
        }
        public function get api_key():String{
            return ((this._currentSession) ? this._currentSession.api_key : null);
        }
        public function get expires():Date{
            return ((this._currentSession) ? this._currentSession.expires : new Date());
        }

    }
}//package com.facebook 
